package com.sxtbbs.util;

import java.io.InputStream;
import java.util.Properties;

import com.sxtbbs.dao.DBDao;

/**
 * 工厂模式创建DBDao实例
 * @author lovemanai
 *
 */
public class DBDaoFactory {
	private static Properties p = null;
	
	static {
		try {
			p = new Properties();
			InputStream in = DBDao.class.getClassLoader().
					getResourceAsStream("daoconfig.properties");
			p.load(in);
		} catch(Exception e) {
			throw new RuntimeException(e);
		}
	}
	
	@SuppressWarnings("rawtypes")
	public static DBDao getDBDao() {
		DBDao dbdao = null;
		try {
		String className = p.getProperty("com.sxtbbs.dao.DBDao");
		Class clazz = Class.forName(className);
		dbdao = (DBDao)clazz.newInstance();
		} catch(Exception e) {
			throw new RuntimeException(e);
		}
		return dbdao;
	}
}
